package cn.tedu.api;

import java.util.LinkedList;

//测试 LinkedList
public class Test2_LinkedList {
    public static void main(String[] args) {
        LinkedList<Integer> linkedList = new LinkedList<>();
        LinkedList<Integer> linkedList2 = new LinkedList<>();

        linkedList.add(1);
        linkedList.add(0,2);
        linkedList.add(3);
        linkedList.add(4);
        linkedList.add(5);
        linkedList.add(2);
        linkedList2.addAll(linkedList);
        linkedList2.addAll(1,linkedList);
        linkedList2.clear();
        System.out.println(linkedList.contains(1));
        System.out.println(linkedList.get(3));
        System.out.println(linkedList.indexOf(2));
        System.out.println(linkedList.lastIndexOf(2));
        linkedList.remove(2);
        linkedList.set(3,9);
        System.out.println(linkedList.size());

        linkedList.addFirst(0);
        linkedList.addLast(9);
        System.out.println(linkedList.getFirst());
        System.out.println(linkedList.getLast());
        System.out.println(linkedList.removeFirst());
        System.out.println(linkedList.removeLast());
    }
}
